﻿using System;
using System.Collections.Generic;
using System.Text;

namespace VSAddinLibrary.Attributes
{
  public class FlagAttribute : Attribute
  {

    #region Constructor
    public FlagAttribute(bool value)
    {
      _value = value;
    }
    #endregion Constructor

    #region Properties

    private bool _value;
    public bool Value
    {
      get { return _value; }
    }
    #endregion Properties

    public static bool GetFlagValue<T>(Type type) where T : FlagAttribute
    {
      bool result = false;
      object[] attributes = type.GetCustomAttributes(typeof(T), true);
      if (attributes.Length == 0)
      {
        return false;
      }
      else
      {
        T flag = attributes[0] as T;
        result = flag.Value;
      }
      return result;

    }
  }
}
